﻿using System;
using BaMusaSoft.RPS.DataModel;
using BaMusaSoft.RPS.RPSServices;

namespace BaMusaSoft.RPS.ViewModel.HelperClasses
{
    /// <summary>
    /// A wrapper around SchedulePrinterService to easing dail with the serivce globally.
    /// </summary>
    internal static class SchedulePrinterHelper
    {
        private static bool _serviceStarted;
        private static SchedulePrinterService _schedulePrinterService;

        internal static void StartService(string scheduleTemplatePath)
        {
            if (scheduleTemplatePath == null) throw new ArgumentNullException("scheduleTemplatePath");
            if (_serviceStarted) return;
            _schedulePrinterService = SchedulePrinterService.Create(scheduleTemplatePath);
            _schedulePrinterService.Start();
            _serviceStarted = true;
        }


        internal static void Print(Schedule schedule)
        {
            if (schedule == null) throw new ArgumentNullException("schedule");
            _schedulePrinterService.AddJob(schedule);
        }

        internal static void StopService()
        {
            _schedulePrinterService.Stop();
            _serviceStarted = false;
        }
        public static bool IsBusy
        {
            get { return _schedulePrinterService.Isbusy; }
        }
        /// <summary>
        /// Use to access the additional feature of the underlying service; aka events subscrition.
        /// </summary>
        public static SchedulePrinterService Service
        {
            get { return _schedulePrinterService; }
        }

    }
}